package com.zjb.demo.system.service;

import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.solon.service.impl.ServiceImpl;
import com.zjb.demo.system.domain.SysNotice;
import com.zjb.demo.system.domain.query.SysNoticeQuery;
import com.zjb.demo.system.mapper.SysNoticeMapper;
import org.noear.solon.annotation.Component;

import static com.zjb.demo.system.domain.table.SysNoticeTableDef.SYS_NOTICE;

/**
 * @author 庄佳彬
 * @since 2023/12/30 22:10
 */
@Component
public class SysNoticeService extends ServiceImpl<SysNoticeMapper, SysNotice> {
    /**
     * 分页查询系统通知列表
     * @param query 查询条件
     * @return 分页结果
     */
    public Page<SysNotice> pageList(SysNoticeQuery query) {
        var page = new Page<SysNotice>(query.getPageNum(), query.getPageSize());
        return queryChain()
                .select(SYS_NOTICE.DEFAULT_COLUMNS)
                .from(SYS_NOTICE)
                .where(SYS_NOTICE.NOTICE_TITLE.like(query.getNoticeTitle()))
                .and(SYS_NOTICE.NOTICE_TYPE.eq(query.getNoticeType()))
                .and(SYS_NOTICE.CREATE_BY.like(query.getCreateBy()))
                .orderBy(SYS_NOTICE.NOTICE_ID.desc())
                .page(page);
    }

}
